<?php

class DatabaseForm extends CFormModel
{
	public $host;
	public $database;
	public $username;
	public $password;
	public $prefix;

	public function rules()
	{
		return array(
			array('host, database, username, password', 'required'),
			array('host,database,username,password,prefix', 'safe'),
		);
	}

	public function attributeLabels()
	{
		return array(
			'host'=>tt('Host'),
			'database'=>tt('Database'),
			'username'=>tt('Username'),
			'password'=>tt('Password'),
			'prefix'=>tt('Prefix'),
		);
	}
	
	protected function beforeValidate()
	{
		foreach ($this->attributes as $key=>$value)
		{
			$this->setAttributes(array($key=>trim($value)));
		}
		return parent::beforeValidate();
	}
}